package com.sky.controller.admin;
import com.sky.dto.ClassPageQueryDTO;
import com.sky.entity.Clazz;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.ClazzService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.baomidou.mybatisplus.core.toolkit.IdWorker.getId;

/**
 * @author LiZhiHan
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("class")

public class ClassController {
    @Autowired ClazzService clazzService;
    @PostMapping("/add")
    public Result addClass(@RequestBody Clazz clazz) {
        log.info("clazz，{}", clazz);
        clazzService.save(clazz);
        return Result.success();
    }
    @DeleteMapping("/del")
    public Result delClass(@RequestBody Clazz clazz) {
        log.info("删除 {}", clazz);
        clazzService.removeById(clazz.getId());
        return Result.success();
    }
    @PutMapping("/update")
    public Result updateClass(@RequestBody Clazz clazz) {
        log.info("更新班级 {}", clazz);
        clazzService.updateById(clazz);
        return  Result.success();
    }


}
